package com.niiwoo.civet.trade.service.loan;

import com.niiwoo.civet.trade.dto.request.*;
import com.niiwoo.civet.trade.dto.request.loan.*;
import com.niiwoo.civet.trade.dto.response.*;
import com.niiwoo.civet.trade.dto.response.loan.ConfirmResponseDTO;
import com.niiwoo.civet.trade.dto.response.loan.ContractPreviewInfoDTO;
import com.niiwoo.civet.trade.dto.response.loan.FadadaWithholdContractSignResponseDTO;
import com.niiwoo.civet.trade.dto.response.loan.LoanLimitResponseDTO;
import com.niiwoo.civet.trade.dto.response.statisticsinfo.FastBorrowAccreditCityResponseDTO;
import com.niiwoo.civet.trade.enums.ProjectFromSourceEnum;
import com.niiwoo.civet.trade.enums.ProjectSubStatusEnum;

import java.math.BigDecimal;
import java.util.List;
import java.util.concurrent.ExecutionException;

/**
 * @Description: 极速借借款服务
 * @Author:LiJian
 * @Date:2017/11/8
 */
public interface SpeedLoanDubboService {

    /**
     * 获取用户极速借资料状态
     * @param userId
     * @return
     */
    SpeedLoanUserDataStatusDTO getSpeedLoanUserDataStatus(String userId);

    /**
     * 获取极速借授信结果
     * @param userId
     * @return
     */
    SpeedLoanCreditResultDTO getSpeedLoanCreditResult(String userId);

    /**
     * 借款检测
     * @param request
     * @return
     */
    SpeedLoanApplyCommonResponseDTO speedLoanPublishCheck(SpeedLoanPublishCheckRequestDTO request);

    /**
     * 获取我的借款配置
     * @return
     */
    SpeedLoanConfigurationResponseDTO speedLoanConfiguration(String userId);

    /**
     * 借款确认提交检查
     * @param deadline
     * @return
     */
    SpeedLoanApplyCommonResponseDTO speedLoanConfirmSubmitCheck(int deadline);

    /**
     * 申请极速借借款
     * @param request
     * @return
     */
    SpeedLoanApplyCommonResponseDTO speedLoanApply(SpeedLoanApplyRequestDTO request);

    /**
     * 退回标的申请极速借借款
     * @param request
     * @return
     */
    SpeedLoanApplyCommonResponseDTO speedLoanApplyForBack(SpeedLoanApplyForBackRequestDTO request);

    /**
     * 退回标的信息查询
     * @param userId
     * @return
     */
    SpeedLoanQueryResponseDTO speedLoanQueryForBack(String userId);

    /**
     * 获取用户极速借额度信息
     * @param userId
     * @return
     */
    SpeedLoanCreditAmountDTO getSpeedLoanCreditAmount(String userId);

    /**
     * 借款反欺诈回调
     * @param loanAgainstFackRequestDTO
     * @return
     */
    void loanAgainstFakeCallback(LoanAgainstFackRequestDTO loanAgainstFackRequestDTO);

    /**
     * 融360标的补偿调用天称信审要点
     */
    default void r360RecallAutoAuditModelJob() {

    }

    /**
     * 信审要点反欺诈回调
     * @param auditPointFackRequestDTO
     */
    void auditPointFakeCallback(AuditPointFackRequestDTO auditPointFackRequestDTO);

    /**
     * 十二项风险规则回调
     * @param riskRuleRequestDTO
     */
    void riskRuleCallback(RiskRuleRequestDTO riskRuleRequestDTO);

    /**
     * 获取借款相关协议信息
     * @param userId
     * @return
     */
    ContractPreviewInfoDTO getContractPreviewInfo(String userId) throws ExecutionException, InterruptedException;

    /**
     * 扫描可推标的标的,并推送至存管;
     */
    void pushProjectScan();

    /**
     * 发起天称十二项风险规则扫描
     */
    void addressList4RiskRuleScan();

    /**
     * 通讯录回流超时标的扫描
     */
    void addressListTimeoutScan();

    /**
     * 通讯录待回流标的扫描
     */
    void addressListScan();

    /**
     * 风险规则超时后继续走后续流程(发起借款反欺诈扫描)
     */
    void riskRuleTimeoutScan();

    /**
     * 清除风险回调记录
     */
    void cleanCallRiskRuleRecord();

    /**
     * 退回超时流标扫描
     */
    void flowReturnTimeoutProjectScan();

    /**
     * 推标
     * @param pushProjectRequestDTO
     */
    void pushProject(PushProjectRequestDTO pushProjectRequestDTO);

    /**
     * 卡牛-推标
     * @param pushProjectRequestDTO
     */
    default void cardNiuPushProject(PushProjectRequestDTO pushProjectRequestDTO){

    }

    /**
     * 查询审核中或未结清标的数量
     * @return
     */
    LoanLimitResponseDTO listProjectInApproveOrNotSettled(String userId);

    /**
     * 查询用户审核中或未结清标的数量,限定标的来源
     * @param userId
     * @param fromSource
     * @return
     */
    LoanLimitResponseDTO listProjectInApproveOrNotSettledWithFromSource(String userId, ProjectFromSourceEnum fromSource);

    /**
     * 用户地址检查检查
     * @param requestDTO
     * @param requestDTO
     */
    SpeedLoanApplyCommonResponseDTO speedLoanPublishCityCheck(SpeedLoanPublishCheckRequestDTO requestDTO);
    
    /**
     * 确认借款
     * @param requestDTO
     */
    void confirmLoan(R360ConfirmLoanRequestDTO requestDTO);

    /**
     * 融360以及借款合同共用用户借款信息表
     * @param projectId
     * @return
     */
    ConfirmResponseDTO userLoanInfo(Long projectId);


    /**
     * 借款确认页面计算（砍头息）
     * @param confirmLoanRequestDTO
     * @return
     */
    ConfirmResponseDTO calculateConfirm(ConfirmLoanRequestDTO confirmLoanRequestDTO);

    /**
     * 借款确认页面需要的还款详情
     * @param loanConfirmRequestDTO
     * @return
     */
    List<RepaymentPlanDTO> repaymentPlan(ConfirmLoanRepaymentPlanRequestDTO loanConfirmRequestDTO);

    /**
     * 还款服务委托书生成
     * @param userId
     * @param projectId
     * @return
     */
    public FadadaWithholdContractSignResponseDTO fadadaWithholdContractSign(String userId,Long projectId);

    /**
     * 获取用户借款成功次数
     * @param userId
     * @return
     */
    public int getUserLoanSuccessTimes(String userId);

    /**
     * 借款每日总次数限制检查
     * @param deadline
     * @param resposeDTO
     */
    public void speedLoanEverydayLoanLimitCheck(int deadline, SpeedLoanApplyCommonResponseDTO resposeDTO);

    /**
     * 退回标的
     * @param projectId
     * @param projectSubStatusEnum
     */
    public void returnProject(Long projectId, ProjectSubStatusEnum projectSubStatusEnum);

    /**
     * 借款服务开放城市
     */
    List<FastBorrowAccreditCityResponseDTO> fastBorrowAccreditCity();

    /**
     * 新增人工审核任务
     * @param projectId
     */
    default void addAuditWorkTask(Long projectId){

    }

    /**
     * 获取极速借剩余可用借款额度
     * @param userId
     * @return
     */
    default BigDecimal getSpeedLoanAviAmount(String userId) {
        return BigDecimal.ZERO;
    }
}
